﻿using IdentityServer4;
using IdentityServer4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NRSoft.IdentityServer.SSOServer.TestData
{
    public class ConfigTestData
    {
        public static IEnumerable<IdentityResource> GetIdentityResources()
        {
            return new List<IdentityResource>
            {
                new IdentityResources.OpenId(),
                new IdentityResources.Profile(),
            };
        }

        // scopes define the API resources in your system
        public static IEnumerable<ApiResource> GetApiResources()
        {
            return new List<ApiResource>
            {
                new ApiResource("api1", "My API")
            };
        }

        // clients want to access resources (aka scopes)
        public static IEnumerable<Client> GetClients()
        {
            // client credentials client
            return new List<Client>
            {
                new Client
                {
                    ClientId = "clientA",
                    AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
                    AllowAccessTokensViaBrowser = true,
                    RequireConsent = false,

                    // 登录后重定向到的地址
                    RedirectUris = { "http://client.ningruisoft.com/signin-oidc", "https://localhost:44324/signin-oidc","http://localhost:61902/signin-oidc",},
                    PostLogoutRedirectUris = { "http://client.ningruisoft.com//signout-callback-oidc", "https://localhost:44324/signout-callback-oidc","http://localhost:61902/signout-callback-oidc" },
                    FrontChannelLogoutUri = "https://localhost:44324/signout-oidc",

                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes = {
                        IdentityServerConstants.StandardScopes.OpenId,
                        IdentityServerConstants.StandardScopes.Profile,
                        "api1"
                    },
                }
            };
        }
    }
}
